
             
/**
 * Copyright (c) 2012-2013 JLLT Corp. 2012-2013,All Rights Reserved.
 * This software is published under the 金麟龙腾商贸有限公司.
 * License version 1.0, a copy of which has been included with this
 * distribution in the LICENSE.txt file.
 *
 * @File name:  TPersonnalDao.java 
 * @Create on:  2012-08-07 23:19:773
 * @Author   :  陈伟
 *
 * @ChangeList
 * ---------------------------------------------------
 * Date         Editor              ChangeReasons
 *
 */
           
package com.boho.ecp.deposit.staff.dao;

            
import java.sql.Connection;

import cn.boho.framework.po.CQuery;
import cn.boho.framework.po.CQueryFactoryTool;
import cn.boho.framework.po.ComboPager;
import cn.boho.framework.po.DAO;
import cn.boho.framework.po.DynaBeanMap;
import cn.boho.framework.po.Pager;

import com.boho.ecp.constant.Staff;
import com.boho.ecp.constant.Store;
            
/**
 * 【员工信息:T_PERSONNAL】的Dao操作类
 * 
 */
public class TPersonnalDao extends DAO {
	
	/**
	* 分页查询所有【员工信息:T_PERSONNAL】信息
	* @param con
	* @param pager
	* @return
	* @throws Exception
	* @date 2012-08-07
	* @author 陈伟
	*
	*/
	public static ComboPager queryTPersonnalByPager(Connection con,Pager pager)throws Exception{
		StringBuffer sql = new StringBuffer();
		sql.append("select * from T_PERSONNAL where IS_VALID = ?");
		CQuery query = CQueryFactoryTool.createFactory().createCQuery();
		query.setInt(1,Staff.VAILD);
		query.setCommand(sql.toString());
		return query.getDynaBeanMapComboPager("T_PERSONNAL", pager,con);
	}
	/**
	* 根据主键【员工编号:PERSONNAL_ID|】获得信息
	* @param con
	* @param personnalId 员工编号
	* @return
	* @throws Exception
	* @date 2012-08-07
	* @author 陈伟
	*
	*/
	public static DynaBeanMap getTPersonnalByPk(Connection con,java.lang.Integer personnalId)throws Exception{
		DynaBeanMap dynaBeanMap = null;
		StringBuffer sql = new StringBuffer();
		sql.append("select * from T_PERSONNAL where PERSONNAL_ID = ? and IS_VALID = ?");
		CQuery query = CQueryFactoryTool.createFactory().createCQuery();
		query.setCommand(sql.toString());
		query.setInt(1,personnalId);
		query.setInt(2,Staff.VAILD);
		dynaBeanMap = query.getDynaBeanMap("T_PERSONNAL", con);
		return dynaBeanMap;
	}
	
	/**
	 * 
	 * @param con
	 * @param personnalNo
	 * @return
	 * @throws Exception
	 */
	public static DynaBeanMap getTPersonnalByPersonnalNo(Connection con, String personnalNo)throws Exception{
		DynaBeanMap dynaBeanMap = null;
		StringBuffer sql = new StringBuffer();
		sql.append("select P.*, S.STORES_NAME, S.ADDRESS, S.PERSONNAL_NO from T_PERSONNAL P, T_STORES S");
		sql.append(" where P.STORES_NO = S.STORES_NO and P.PERSONNAL_NO = ? and P.IS_VALID = ? and S.IS_VALID = ?");
		CQuery query = CQueryFactoryTool.createFactory().createCQuery();
		query.setCommand(sql.toString());
		query.setString(1,personnalNo);
		query.setInt(2,Staff.VAILD);
		query.setInt(3,Staff.VAILD);
		dynaBeanMap = query.getDynaBeanMap("T_PERSONNAL", con);
		return dynaBeanMap;
	}
	
}
